#include <Klein/Shader/GraphDatabase.h>

bool GraphDatabase::AddGraph(const GraphRef& graph)
{
	const String& graphCompleteName = graph->GetIdentifier().GetGraphCompleteName();
	if (mGraphs.find(graphCompleteName) == mGraphs.end())
	{
		mGraphs.insert(std::make_pair(graphCompleteName, graph));

		mActivedGraphName = graphCompleteName;

		return true;
	}

	return false;
}

void GraphDatabase::ActiveGraph(const String& graphName)
{
	mActivedGraphName = graphName;
}

GraphRef GraphDatabase::GetActivedGraph() const
{
	std::map<String, GraphRef>::const_iterator itr = mGraphs.find(mActivedGraphName);
	assert(itr != mGraphs.end());

	return itr->second;
}
